package org.example.springchatroom.model;

import lombok.Data;
import org.example.springchatroom.enums.Enums;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/9/3
 * Time: 14:54
 */
@Data
public class Result<T> {
    private T data;
    private Enums status;
    private String error;

    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>();
        result.setData(data);
        result.setStatus(Enums.SUCCESS);
        result.setError(null);
        return result;
    }
    public static <T> Result<T> fail(String error){
        Result<T> result = new Result<>();
        result.setData(null);
        result.setStatus(Enums.FAIL);
        result.setError(error);
        return result;
    }
}
